package com.maket.jbxx.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.maket.jbxx.domain.WldaMaterialFile;
import com.maket.jbxx.service.IWldaMaterialFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 物料档案Controller
 * 
 * @author ruoyi
 * @date 2024-07-06
 */
@RestController
@RequestMapping("/wlMess")
public class WldaMaterialFileController extends BaseController
{
    @Autowired
    private IWldaMaterialFileService wldaMaterialFileService;

    /**
     * 查询物料档案列表
     */
    @RequiresPermissions("jbxx:wlMess:list")
    @GetMapping("/list")
    public TableDataInfo list(WldaMaterialFile wldaMaterialFile)
    {
        startPage();
        List<WldaMaterialFile> list = wldaMaterialFileService.selectWldaMaterialFileList(wldaMaterialFile);
        return getDataTable(list);
    }

    /**
     * 导出物料档案列表
     */
    @RequiresPermissions("jbxx:wlMess:export")
    @Log(title = "物料档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WldaMaterialFile wldaMaterialFile)
    {
        List<WldaMaterialFile> list = wldaMaterialFileService.selectWldaMaterialFileList(wldaMaterialFile);
        ExcelUtil<WldaMaterialFile> util = new ExcelUtil<WldaMaterialFile>(WldaMaterialFile.class);
        util.exportExcel(response, list, "物料档案数据");
    }

    /**
     * 获取物料档案详细信息
     */
    @RequiresPermissions("jbxx:wlMess:query")
    @GetMapping(value = "/{wlCode}")
    public AjaxResult getInfo(@PathVariable("wlCode") String wlCode)
    {
        return success(wldaMaterialFileService.selectWldaMaterialFileByWlCode(wlCode));
    }

    /**
     * 新增物料档案
     */
    @RequiresPermissions("jbxx:wlMess:add")
    @Log(title = "物料档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WldaMaterialFile wldaMaterialFile)
    {
        return toAjax(wldaMaterialFileService.insertWldaMaterialFile(wldaMaterialFile));
    }

    /**
     * 修改物料档案
     */
    @RequiresPermissions("jbxx:wlMess:edit")
    @Log(title = "物料档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WldaMaterialFile wldaMaterialFile)
    {
        return toAjax(wldaMaterialFileService.updateWldaMaterialFile(wldaMaterialFile));
    }

    /**
     * 删除物料档案
     */
    @RequiresPermissions("jbxx:wlMess:remove")
    @Log(title = "物料档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wlCodes}")
    public AjaxResult remove(@PathVariable String[] wlCodes)
    {
        return toAjax(wldaMaterialFileService.deleteWldaMaterialFileByWlCodes(wlCodes));
    }
}
